# encoding=utf-8
from __future__ import division
import json
import MySQLdb
import datetime
import time
import sys
from powerRules import payfrequency, yearGrowthRate, twoYearsOfGrowth, breakContractRatio
from powerRules import overageAdequateRate, eleCostsfrequency, breakContractFrequency, breakContractMoney, debt

jsonDic = {}

from DBStory import cursor


# 用电量连续两年增长情况
def gettwoYearsOfGrowthScore():
    print "ACCOUNT_NUM_value"
    print ACCOUNT_NUM_value
    now = datetime.datetime.now()
    last_year = int(now.year) - 1

    if now.month == '01':
        nowYearMonth = '%s%s' % (now.year - 1, 12)
        lastYearMonth = '%s%s' % (last_year - 1, 12)
        beforeYearMonth = '%s%s' % (last_year - 2, 12)
    else:
        nowYearMonth = '%s%s' % (now.year, now.month - 1)
        lastYearMonth = '%s%s' % (last_year, now.month - 1)
        beforeYearMonth = '%s%s' % (last_year - 1, now.month - 1)
    scorelist = []
    score1 = 0
    for i in range(len(valueList)):
        ACCOUNT_NUM = valueList[i]
        last_TSETTLE_PQ_sql = 'select TSETTLE_PQ from DED_ENT_ELEC_CONSUME where POWER_ACCOUNT_NUM = %s AND YM = %s' % (
            ACCOUNT_NUM, nowYearMonth)
        cursor.execute(last_TSETTLE_PQ_sql)
        try:
            last_TSETTLE_PQ = cursor.fetchone()[0]
        except:
            last_TSETTLE_PQ = 0

        last_year_TSETTLE_PQ_sql = 'select TSETTLE_PQ from DED_ENT_ELEC_CONSUME where POWER_ACCOUNT_NUM = %s AND YM = %s' % (
            ACCOUNT_NUM, lastYearMonth)
        cursor.execute(last_year_TSETTLE_PQ_sql)
        try:
            last_year_TSETTLE_PQ = cursor.fetchone()[0]
        except:
            last_year_TSETTLE_PQ = 0

        before_year_TSETTLE_PQ_sql = 'select TSETTLE_PQ from DED_ENT_ELEC_CONSUME where POWER_ACCOUNT_NUM = %s AND YM = %s' % (
            ACCOUNT_NUM, beforeYearMonth)
        cursor.execute(before_year_TSETTLE_PQ_sql)
        try:
            before_year_TSETTLE_PQ = cursor.fetchone()[0]
        except:
            before_year_TSETTLE_PQ = 0

        twoYearsOfGrowthScore = twoYearsOfGrowth(last_TSETTLE_PQ, last_year_TSETTLE_PQ, before_year_TSETTLE_PQ)
        print "twoYearsOfGrowthScore"
        print twoYearsOfGrowthScore
        scorelist.append(twoYearsOfGrowthScore)
        if str(ACCOUNT_NUM) == str(ACCOUNT_NUM_value):
            score1 = twoYearsOfGrowthScore

    print "scorelist"
    print scorelist
    scoreMax = max(scorelist)
    scoreMin = min(scorelist)
    print "score1"
    print score1
    print "scoreMax"
    print scoreMax
    print "scoreMin"
    print scoreMin
    if scoreMin == scoreMax:
        tmpScore = 1
    else:
        tmpScore = (score1 - scoreMin) / (scoreMax - scoreMin)
    finallyScore = tmpScore * 0.5 * 1 * 0.2
    print "用电量连续两年增长情况finallyScore"
    print finallyScore
    tmpdic = {
        'name': '用电量连续两年增长情况',
        'score': finallyScore,
        'value': score1
    }
    jsonDic["twoyearsgrowth"] = tmpdic
    return finallyScore


# 年度用户电量同比增长率
def getyearGrowthRateScore():
    now = datetime.datetime.now()
    last_year = int(now.year) - 1

    if now.month == '01':
        nowYearMonth = '%s%s' % (now.year - 1, 12)
        lastYearMonth = '%s%s' % (last_year - 1, 12)
    else:
        nowYearMonth = '%s%s' % (now.year, now.month - 1)
        lastYearMonth = '%s%s' % (last_year, now.month - 1)
    scorelist = []
    score1 = 0
    for i in range(len(valueList)):
        ACCOUNT_NUM = valueList[i]
        last_TSETTLE_PQ_sql = 'select TSETTLE_PQ from DED_ENT_ELEC_CONSUME where POWER_ACCOUNT_NUM = %s AND YM = %s' % (
            ACCOUNT_NUM, nowYearMonth)
        cursor.execute(last_TSETTLE_PQ_sql)
        try:
            last_TSETTLE_PQ = cursor.fetchone()[0]
        except:
            last_TSETTLE_PQ = 0

        before_TSETTLE_PQ_sql = 'select TSETTLE_PQ from DED_ENT_ELEC_CONSUME where POWER_ACCOUNT_NUM = %s AND YM = %s' % (
            ACCOUNT_NUM, lastYearMonth)
        cursor.execute(before_TSETTLE_PQ_sql)
        try:
            before_TSETTLE_PQ = cursor.fetchone()[0]
        except:
            before_TSETTLE_PQ = 0
        yearGrowthRateScore = yearGrowthRate(last_TSETTLE_PQ, before_TSETTLE_PQ)
        scorelist.append(yearGrowthRateScore)
        if str(ACCOUNT_NUM) == str(ACCOUNT_NUM_value):
            score1 = yearGrowthRateScore

        print "yearGrowthRateScore"
        print yearGrowthRateScore
        # return yearGrowthRateScore
    print "scorelist"
    print scorelist
    scoreMax = max(scorelist)
    scoreMin = min(scorelist)
    print "score1"
    print score1
    print "scoreMax"
    print scoreMax
    print "scoreMin"
    print scoreMin
    if scoreMin == scoreMax:
        tmpScore = 1
    else:
        tmpScore = (score1 - scoreMin) / (scoreMax - scoreMin)
    finallyScore = tmpScore * 0.5 * 1 * 0.2
    print "年度用户电量同比增长率finallyScore"
    print finallyScore

    tmpdic = {
        'name': '年度用户电量同比增长率',
        'score': finallyScore,
        'value': score1
    }
    jsonDic["yeargrowth"] = tmpdic
    return finallyScore


# 欠款
def getDebtScore():
    now = datetime.datetime.now()
    last_year = int(now.year) - 1
    print last_year
    lastYearMonth = '%s%s' % (last_year, now.month)
    print lastYearMonth
    scorelist = []
    score1 = 0
    for i in range(len(valueList)):
        ACCOUNT_NUM = valueList[i]
        PREPAY_BAL_sql = 'select OWE_AMT,RCVBL_AMT from DED_ENT_CUST_SHOULDPAY where POWER_ACCOUNT_NUM = %s AND RCVBL_YM > %s' % (
            ACCOUNT_NUM, lastYearMonth)
        cursor.execute(PREPAY_BAL_sql)
        all_LIST = cursor.fetchall()
        OWE_AMT_LIST = list(float(x[0]) for x in all_LIST)
        RCVBL_AMT_LIST = list(float(x[1]) for x in all_LIST)
        debtScore = debt(OWE_AMT_LIST, RCVBL_AMT_LIST)
        print "debtScore"
        print debtScore
        scorelist.append(debtScore)
        if str(ACCOUNT_NUM) == str(ACCOUNT_NUM_value):
            score1 = debtScore

    print "scorelist"
    print scorelist
    scoreMax = max(scorelist)
    scoreMin = min(scorelist)
    print "score1"
    print score1
    print "scoreMax"
    print scoreMax
    print "scoreMin"
    print scoreMin
    if scoreMin == scoreMax:
        tmpScore = 1
    else:
        tmpScore = (scoreMax - score1) / (scoreMax - scoreMin)
    finallyScore = tmpScore * 0.2 * 0.5 * 0.3
    print "欠款finallyScore"
    print finallyScore

    tmpdic = {
        'name': '欠款',
        'score': finallyScore,
        'value': score1
    }
    jsonDic["debt"] = tmpdic

    return finallyScore


# 是否停电
def getPowerDownScore():
    POWER_OFF_sql = 'select POWER_OFF_CODE from DED_ENT_POWER_BASEINFO where POWER_ACCOUNT_NUM = %s' % (
        ACCOUNT_NUM_value)
    cursor.execute(POWER_OFF_sql)
    try:
        POWER_OFF = cursor.fetchone()[0]
    except:
        POWER_OFF = "未实施停电"

    POWER_OFF_rate = 1
    if POWER_OFF == "未实施停电":
        POWER_OFF_rate = 1
    else:
        POWER_OFF_rate = 0
    finallyScore = POWER_OFF_rate * 0.3 * 0.5
    tmpdic = {
        'name': '违约金比率',
        'score': finallyScore,
        'value': finallyScore
    }
    jsonDic["powerdown"] = tmpdic
    return finallyScore


# 违约金比率
def getbreakContractMoneyScore():
    now = datetime.datetime.now()
    last_year = int(now.year) - 1
    print last_year
    lastYearMonth = '%s%s' % (last_year, now.month)
    print lastYearMonth
    scorelist = []
    score1 = 0
    for i in range(len(valueList)):
        ACCOUNT_NUM = valueList[i]
        PREPAY_BAL_sql = 'select RCVBL_PENALTY,RCVBL_AMT from DED_ENT_CUST_SHOULDPAY where POWER_ACCOUNT_NUM = %s AND RCVBL_YM > %s' % (
            ACCOUNT_NUM, lastYearMonth)
        cursor.execute(PREPAY_BAL_sql)
        all_LIST = cursor.fetchall()
        RCVBL_PENALTY_LIST = list(float(x[0]) for x in all_LIST)
        RCVBL_AMT_LIST = list(float(x[1]) for x in all_LIST)
        breakContractMoneyScore = breakContractMoney(RCVBL_PENALTY_LIST, RCVBL_AMT_LIST)
        print "breakContractMoneyScore"
        print breakContractMoneyScore
        scorelist.append(breakContractMoneyScore)
        if str(ACCOUNT_NUM) == str(ACCOUNT_NUM_value):
            score1 = breakContractMoneyScore

            # return breakContractMoneyScore
    print "scorelist"
    print scorelist
    scoreMax = max(scorelist)
    scoreMin = min(scorelist)
    print "score1"
    print score1
    print "scoreMax"
    print scoreMax
    print "scoreMin"
    print scoreMin
    if scoreMin == scoreMax:
        tmpScore = 1
    else:
        tmpScore = (score1 - scoreMin) / (scoreMax - scoreMin)
    finallyScore = tmpScore * 0.3 * 0.5 * 0.3
    print "违约金比率finallyScore"
    print finallyScore
    tmpdic = {
        'name': '违约金比率',
        'score': finallyScore,
        'value': score1
    }
    jsonDic["brecontractper"] = tmpdic
    return finallyScore


# 违约金频率
def getbreakContractRatio():
    now = datetime.datetime.now()
    last_year = int(now.year) - 1
    print last_year
    lastYearMonth = '%s%s' % (last_year, now.month)
    print lastYearMonth
    scorelist = []
    score1 = 0
    for i in range(len(valueList)):
        ACCOUNT_NUM = valueList[i]
        RELEASE_DATE_sql = 'select RELEASE_DATE from DED_ENT_CUST_SHOULDPAY where POWER_ACCOUNT_NUM = %s AND RCVBL_YM > %s' % (
            ACCOUNT_NUM, lastYearMonth)
        cursor.execute(RELEASE_DATE_sql)
        RELEASE_DATE_LIST = cursor.fetchall()
        RELEASE_DATE_LIST = list(x[0] for x in RELEASE_DATE_LIST)

        PENALTY_BGN_DATE_sql = 'select PENALTY_BGN_DATE from DED_ENT_CUST_SHOULDPAY where POWER_ACCOUNT_NUM = %s AND RCVBL_YM > %s' % (
            ACCOUNT_NUM, lastYearMonth)
        cursor.execute(PENALTY_BGN_DATE_sql)
        PENALTY_BGN_DATE_LIST = cursor.fetchall()
        PENALTY_BGN_DATE_LIST = list(x[0] for x in PENALTY_BGN_DATE_LIST)

        deltaDayslist = []
        for i in range(len(RELEASE_DATE_LIST)):
            dt1 = str(RELEASE_DATE_LIST[i])
            dt1 = "%s-%s-%s" % (dt1[0:4], dt1[4:6], dt1[6:8])
            print "dt1"
            print dt1

            dt2 = str(PENALTY_BGN_DATE_LIST[i])
            dt2 = "%s" % (dt2[0:10])
            print "dt2"
            print dt2
            d1 = datetime.datetime.strptime(dt1, '%Y-%m-%d')
            d2 = datetime.datetime.strptime(dt2, '%Y-%m-%d')
            delta = d2 - d1
            deltaDayslist.append(delta.days)

        print "deltaDayslist"
        print deltaDayslist
        breakContractRatioScore = breakContractRatio(deltaDayslist)
        scorelist.append(breakContractRatioScore)
        if str(ACCOUNT_NUM) == str(ACCOUNT_NUM_value):
            score1 = breakContractRatioScore

            # print "breakContractRatioScore"
            # print breakContractRatioScore
            # # 时间标准差不会弄，暂时搁置
            # return breakContractRatioScore
    print "scorelist"
    print scorelist
    scoreMax = max(scorelist)
    scoreMin = min(scorelist)
    print "score1"
    print score1
    print "scoreMax"
    print scoreMax
    print "scoreMin"
    print scoreMin
    if scoreMin == scoreMax:
        tmpScore = 1
    else:
        tmpScore = (scoreMax - score1) / (scoreMax - scoreMin)
    finallyScore = tmpScore ** 0.3 * 0.5 * 0.3
    print "违约金频率finallyScore"
    print finallyScore
    tmpdic = {
        'name': '违约金频率',
        'score': finallyScore,
        'value': score1
    }
    jsonDic["brecontractrate"] = tmpdic
    return finallyScore


# 缴费频率的稳定性
def getpayfrequencyScore():
    now = datetime.datetime.now()
    last_year = int(now.year) - 1
    print last_year
    lastYearMonth = '%s%s' % (last_year, now.month)
    print lastYearMonth
    scorelist = []
    score1 = 0
    for i in range(len(valueList)):
        ACCOUNT_NUM = valueList[i]
        PREPAY_BAL_sql = 'select RCVED_DATE from DED_ENT_CUST_REALPAY where POWER_ACCOUNT_NUM = %s AND RCVED_YM > %s' % (
            ACCOUNT_NUM, lastYearMonth)
        cursor.execute(PREPAY_BAL_sql)
        RCVED_DATE_LIST = cursor.fetchall()
        RCVED_DATE_LIST = list(x[0] for x in RCVED_DATE_LIST)
        print "RCVED_DATE_LIST====="
        deltaDayslist = []
        for i in range(len(RCVED_DATE_LIST) - 1):
            dt1 = str(RCVED_DATE_LIST[i])
            dt1 = "%s-%s-%s" % (dt1[0:4], dt1[4:6], dt1[6:8])
            print "dt1"
            print dt1

            dt2 = str(RCVED_DATE_LIST[i + 1])
            dt2 = "%s-%s-%s" % (dt2[0:4], dt2[4:6], dt2[6:8])
            print "dt2"
            print dt2
            d1 = datetime.datetime.strptime(dt1, '%Y-%m-%d')
            d2 = datetime.datetime.strptime(dt2, '%Y-%m-%d')
            delta = d2 - d1
            deltaDayslist.append(delta.days)

        print "deltaDayslist"
        print deltaDayslist
        payfrequencyScore = payfrequency(deltaDayslist)
        print "payfrequencyScore"
        print payfrequencyScore
        scorelist.append(payfrequencyScore)
        print 'i'
        print i
        print scorelist
        if str(ACCOUNT_NUM) == str(ACCOUNT_NUM_value):
            score1 = payfrequencyScore

    print "scorelist"
    print scorelist
    scoreMax = max(scorelist)
    scoreMin = min(scorelist)
    print "score1"
    print score1
    print "scoreMax"
    print scoreMax
    print "scoreMin"
    print scoreMin
    if scoreMin == scoreMax:
        tmpScore = 1
    else:
        tmpScore = (scoreMax - score1) / (scoreMax - scoreMin)
    finallyScore = tmpScore * 0.1 * 0.5 * 0.3
    print "缴费频率的稳定性finallyScore"
    print finallyScore
    tmpdic = {
        'name': '缴费频率的稳定性',
        'score': finallyScore,
        'value': score1
    }
    jsonDic["paystable"] = tmpdic
    return finallyScore

    # 时间标准差不会弄，暂时搁置


# 违约金回收率
def getbreakContractFrequencyScore():
    now = datetime.datetime.now()
    last_year = int(now.year) - 1
    print last_year
    lastYearMonth = '%s%s' % (last_year, now.month)
    print lastYearMonth
    scorelist = []
    score1 = 0
    for i in range(len(valueList)):
        ACCOUNT_NUM = valueList[i]
        PREPAY_BAL_sql = 'select RCVBL_PENALTY from DED_ENT_CUST_SHOULDPAY where POWER_ACCOUNT_NUM = %s AND RCVBL_YM > %s' % (
            ACCOUNT_NUM, lastYearMonth)
        cursor.execute(PREPAY_BAL_sql)
        RCVBL_PENALTY_LIST = cursor.fetchall()
        print RCVBL_PENALTY_LIST

        RCVBL_PENALTY_LIST = list(float(x[0]) for x in RCVBL_PENALTY_LIST)
        print RCVBL_PENALTY_LIST
        print 'sum(PREPAY_BAL_LIST)'
        print  sum(RCVBL_PENALTY_LIST)

        RCVED_PENALTY_sql = 'select RCVED_PENALTY from DED_ENT_CUST_SHOULDPAY where POWER_ACCOUNT_NUM = %s AND RCVBL_YM > %s' % (
            ACCOUNT_NUM, lastYearMonth)
        print RCVED_PENALTY_sql
        cursor.execute(RCVED_PENALTY_sql)
        RCVED_PENALTY_LIST = cursor.fetchall()
        print RCVED_PENALTY_LIST
        RCVED_PENALTY_LIST = list(float(x[0]) for x in RCVED_PENALTY_LIST)
        print RCVED_PENALTY_LIST
        print sum(RCVED_PENALTY_LIST)
        breakContractFrequencyScore = breakContractFrequency(RCVED_PENALTY_LIST, RCVBL_PENALTY_LIST)
        print 'breakContractFrequencyScore'
        print breakContractFrequencyScore
        scorelist.append(breakContractFrequencyScore)
        if str(ACCOUNT_NUM) == str(ACCOUNT_NUM_value):
            score1 = breakContractFrequencyScore

    print "scorelist"
    print scorelist
    scoreMax = max(scorelist)
    scoreMin = min(scorelist)
    print "score1"
    print score1
    print "scoreMax"
    print scoreMax
    print "scoreMin"
    print scoreMin
    if scoreMin == scoreMax:
        tmpScore = 1
    else:
        tmpScore = (score1 - scoreMin) / (scoreMax - scoreMin)

    finallyScore = tmpScore * 0.4 * 0.5 * 0.3
    print "违约金回收率finallyScore"
    print finallyScore
    tmpdic = {
        'name': '违约金回收率',
        'score': finallyScore,
        'value': score1
    }
    jsonDic["brecontractreco"] = tmpdic
    return finallyScore


# 电费回收率
def geteleCostsfrequency():
    now = datetime.datetime.now()
    last_year = int(now.year) - 1
    print last_year
    lastYearMonth = '%s%s' % (last_year, now.month)
    print lastYearMonth
    global valueList
    scorelist = []
    score1 = 0
    for i in range(len(valueList)):
        ACCOUNT_NUM = valueList[i]
        PREPAY_BAL_sql = 'select RCVBL_AMT from DED_ENT_CUST_SHOULDPAY where POWER_ACCOUNT_NUM = %s AND RCVBL_YM > %s' % (
        ACCOUNT_NUM, lastYearMonth)
        cursor.execute(PREPAY_BAL_sql)
        PREPAY_BAL_LIST = cursor.fetchall()
        print PREPAY_BAL_LIST

        PREPAY_BAL_LIST = list(float(x[0]) for x in PREPAY_BAL_LIST)
        print PREPAY_BAL_LIST
        print 'sum(PREPAY_BAL_LIST)'
        print  sum(PREPAY_BAL_LIST)

        THIS_RCVED_AMT_sql = 'select THIS_RCVED_AMT from DED_ENT_CUST_REALPAY where POWER_ACCOUNT_NUM = %s AND RCVED_YM > %s' % (
            ACCOUNT_NUM, lastYearMonth)
        print THIS_RCVED_AMT_sql
        cursor.execute(THIS_RCVED_AMT_sql)
        THIS_RCVED_AMT_LIST = cursor.fetchall()
        print THIS_RCVED_AMT_LIST
        THIS_RCVED_AMT_LIST = list(float(x[0]) for x in THIS_RCVED_AMT_LIST)
        print THIS_RCVED_AMT_LIST
        print sum(THIS_RCVED_AMT_LIST)
        eleCostsfrequencyScore = eleCostsfrequency(THIS_RCVED_AMT_LIST, PREPAY_BAL_LIST)
        scorelist.append(eleCostsfrequencyScore)
        if str(ACCOUNT_NUM) == str(ACCOUNT_NUM_value):
            score1 = eleCostsfrequencyScore

    print "scorelist"
    print scorelist
    scoreMax = max(scorelist)
    scoreMin = min(scorelist)
    print "score1"
    print score1
    print "scoreMax"
    print scoreMax
    print "scoreMin"
    print scoreMin
    if scoreMin == scoreMax:
        tmpScore = 1
    else:
        tmpScore = (score1 - scoreMin) / (scoreMax - scoreMin)
    finallyScore = tmpScore * 0.4 * 0.5 * 0.3
    print "电费回收率finallyScore"
    print finallyScore
    tmpdic = {
        'name': '电费回收率',
        'score': finallyScore,
        'value': score1
    }
    jsonDic["elerecover"] = tmpdic
    return finallyScore


# 用户余额充足率
def getoverageAdequateRate():
    print "here"
    check_month = 201506
    global valueList
    scorelist = []
    score1 = 0
    for i in range(len(valueList)):
        ACCOUNT_NUM = valueList[i]
        PREPAY_BAL_sql = 'select PREPAY_BAL from DED_ENT_POWER_BASEINFO where POWER_ACCOUNT_NUM = %s' % ACCOUNT_NUM
        cursor.execute(PREPAY_BAL_sql)
        try:
            PREPAY_BAL = cursor.fetchone()[0]
        except:
            PREPAY_BAL = 0
        if PREPAY_BAL is None:
            PREPAY_BAL = 0
        print PREPAY_BAL
        RCVBL_AMT_sql = 'select RCVBL_AMT from DED_ENT_CUST_SHOULDPAY where POWER_ACCOUNT_NUM = %s AND RCVBL_YM = %s' % (
        ACCOUNT_NUM, check_month)
        cursor.execute(RCVBL_AMT_sql)
        try:
            RCVBL_AMT = cursor.fetchone()[0]
        except:
            RCVBL_AMT = 0
        print RCVBL_AMT
        overageAdequateRateScore = overageAdequateRate(PREPAY_BAL, RCVBL_AMT)
        scorelist.append(overageAdequateRateScore)
        if str(ACCOUNT_NUM) == str(ACCOUNT_NUM_value):
            score1 = overageAdequateRateScore
    print "scorelist"
    print scorelist
    scoreMax = max(scorelist)
    scoreMin = min(scorelist)
    print "score1"
    print score1
    print "scoreMax"
    print scoreMax
    print "scoreMin"
    print scoreMin
    if scoreMax == scoreMin:
        tmpScore = 1
    else:
        tmpScore = (score1 - scoreMin) / (scoreMax - scoreMin)
    finallyScore = tmpScore * 0.2 * 0.5 * 0.3
    print "用户余额充足率finallyScore"
    print finallyScore
    tmpdic = {
        'name': '用户余额充足率',
        'score': finallyScore,
        'value': score1
    }
    jsonDic["overage"] = tmpdic
    return finallyScore
    # return overageAdequateRateScore


def getAllScore(nameValue):
    # global cursor
    # db = MySQLdb.connect(host='192.168.80.159', user="mydb3", passwd="mydb3", db="mydb3")
    # cursor = db.cursor()
    global ACCOUNT_NUM_value
    ACCOUNT_NUM_value = nameValue
    print ACCOUNT_NUM_value
    global valueList, jsonDic
    jsonDic.clear()
    valuelist_sql = "select `POWER_ACCOUNT_NUM` from `DED_ENT_POWER_BASEINFO`"
    cursor.execute(valuelist_sql)
    valueList = cursor.fetchall()
    valueList = list(int(x[0]) for x in valueList)
    print valueList
    getpayfrequencyScore()
    getPowerDownScore()
    getDebtScore()
    getbreakContractMoneyScore()
    geteleCostsfrequency()
    getoverageAdequateRate()
    getbreakContractFrequencyScore()
    gettwoYearsOfGrowthScore()
    getyearGrowthRateScore()
    getbreakContractRatio()

    # sumScore = sum(jsonDic[key]["score"] for key in jsonDic)
    # print "sumScore"
    # print sumScore
    # print jsonDic
    return jsonDic





    #
    #
    # if __name__ == '__main__':
    #     global cursor
    #     db = MySQLdb.connect(host='192.168.80.159', user="mydb3", passwd="mydb3", db="mydb3")
    #     cursor = db.cursor()
    #     getAllScore()
